﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Microsoft.Bing
{
    /// <summary>
    /// Implements an event argument type for encapsulating a search error passed by an <see cref="ISearchEngine"/> implementation.
    /// </summary>
    public class ErrorEventArgs : EventArgs
    {
        /// <summary>
        /// The <see cref="System.Exception"/> thrown originally.
        /// </summary>
        public readonly Exception Error = null;

        /// <summary>
        /// A boolean value which indicates whether the Search network call was cancelled by the runtime or the user
        /// </summary>
        public readonly bool Cancelled = false;
        
        /// <summary>
        /// An object identifying the custom user state passed to the original search call
        /// </summary>
        public object   UserState = null;

        /// <summary>
        /// Instantitates a <see cref="ErrorEventArgs"/> instance.
        /// </summary>
        /// <param name="ex">The <see cref="System.Exception"/> thrown (or null)</param>
        /// <param name="cancelled">A boolean value indicating whether the asynchronous call was cancelled</param>
        /// <param name="userState">The custom user state</param>
        public ErrorEventArgs(Exception ex, bool cancelled, object userState)
        {
            this.Error = ex;
            this.Cancelled = cancelled;
            this.UserState = userState;
        }
    }
}
